package org.biubiu0002.baiblog.core.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: biubiu0002
 * @Date: 2022-05-14 10:58
 **/
@Configuration
@ConfigurationProperties("redisson")
@Data
public class RedissonConfig {

    private String address;
    private String password;

    @Bean(destroyMethod = "shutdown")
    public RedissonClient getRedissonClient(){
        Config config = new Config();
        config.useSingleServer().setAddress(address);
        config.useSingleServer().setPassword(password);
        return Redisson.create(config);

    }

}
